home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 32
/
Mac Magazin and MacEasy Magazine CD - Issue 32.iso
/
Grafik & Text
/
Fractal Trees
/
Sources etc
/
Fractal Trees 2.cpp
next >
Wrap
C/C++ Source or Header
|
1997-02-11
|
2KB
|
152 lines
#include "FractalTreeObject.cpp"
#define kBaseResID 128
#define kMoveToFront (WindowPtr)-1L
#define kFontSize 9
#define kSleep 1L
// Globals
Boolean gDone;
// ****************************************************************
// Prototypes
void ToolBoxInit();
void WindowInit();
void MainLoop();
void EventInit();
void HandleMouseDown( EventRecord *event );
// ****************************************************************
// Main
void main()
{
ToolBoxInit();
WindowInit();
MainLoop();
}
// ****************************************************************
// ToolBoxInit
void ToolBoxInit()
{
InitGraf( &qd.thePort );
InitFonts();
InitWindows();
InitMenus();
TEInit();
InitDialogs( nil );
InitCursor();
}
// ****************************************************************
// WindowInit
void WindowInit()
{
WindowPtr window;
Rect windRect;
window = GetNewWindow( kBaseResID, nil, kMoveToFront );
if (window == nil)
{
SysBeep( 10 ); // couldn't load wind resource
ExitToShell();
}
SetPort( window );
TextSize( kFontSize );
ShowWindow( window );
}
// ****************************************************************
// EventInit
void EventInit()
{
OSErr err;
long result;
err = Gestalt(gestaltAppleEventsAttr, &result);
}
// ****************************************************************
// MainLoop
void MainLoop()
{
EventRecord event;
int drawDone = 0;
FractalTree Tree1(14, 0.69, 3.1415926/8, 0.3, 0.9); // tested up to 17 at 20000 K
gDone = false;
while (gDone == false)
{
if (drawDone == 0)
{
Tree1.GrowTree();
Tree1.DrawTree();
drawDone = 1;
}
WaitNextEvent(everyEvent, &event, kSleep, NULL);
switch ( event.what )
{
case mouseDown:
HandleMouseDown( &event );
break;
}
}
}
// ****************************************************************
// HandleMouseDown
void HandleMouseDown( EventRecord *event )
{
WindowPtr window;
short windowPart;
windowPart = FindWindow( event->where, &window );
switch ( windowPart )
{
case inSysWindow:
SystemClick( event, window );
break;
case inDrag:
DragWindow( window, event->where, &(qd.screenBits.bounds) );
break;
case inGoAway:
gDone = true;
break;
}
}